<?php

$status = '';
$turma = '';
$img = '';

$db = Zend_Db_Table_Abstract::getDefaultAdapter(); 

function sel_menu($action,$op){
    if($action == $op) echo 'class="sel"';
}

if($this->data['ALU_ID'] > 0){
    
    $query = 'SELECT SQL_CACHE m.MAT_ID,m.MAT_STA,c.CUR_ID '
            .' FROM MATRICULA m, CURSO c '
            .' WHERE m.CUR_ID = c.CUR_ID AND m.ALU_ID = ' . $this->data['ALU_ID']
            .' AND m.MAT_STA = 1 ORDER BY m.MAT_DAT DESC';
    $row = $db->fetchRow($query);
    
    $status = strtoupper(aluno::returnStatusAluno($this->data['ALU_ID']));
    
    
    if(isset($row['MAT_STA']) && $row['MAT_STA'] == 0){ 
        $query = 'SELECT SQL_CACHE FIL_ID FROM FILA_MATRICULA WHERE MAT_ID = ' . $row['MAT_ID'];
        $r_fila = $db->fetchRow($query);
        if(isset($r_fila['FIL_ID']) && $r_fila['FIL_ID'] > 0) $status =  '<span class="aln_fila">FILA DE ESPERA</span>';
    }
    
    //if($this->data['ALU_STA'] == 0) $status =  '<span class="aln_ex">'.$status.'</span>';
    //$turma = $r_cur['CUR_NOM'].' | '.dominio::getTurno($r_cur['TUR_ID']).' | '.$r_cur['CUR_TRM'].' | '.$r_cur['CUR_ANO'].' | '.dominio::getSemestres($r_cur['CUR_SEM']);
    
    $turma = '';
    if(isset($row['CUR_ID']) && $row['CUR_ID'] > 0) $turma = dominio::getTurma($row['CUR_ID']);
    
    $imgs = 'public/upload/aluno/'.$this->data['ALU_ID'].'_det.*';
    foreach (glob($imgs) as $src) {
        $img = $src;
    }
}
?>

    <div class="content-laterial">
        <div class="content-img">
            <div class="cnt-img">
                <?php if(strlen($img) > 10){ ?>
                <img src="<?php echo '/'.$img; ?>" />  
                <?php } ?>
            </div>
            <?php if($this->data['ALU_ID'] > 0){ ?>
            <div class="cnt-btna">
                <a href="<?php echo $this->urlbase.'/'.$this->modulo.'/'.$this->controller.'/foto/id/'.$this->data['ALU_ID']; ?>" class="btn-pdr">Cadastrar Foto</a>
            </div>
            <?php } ?>
        </div>
        <ul class="menu">
            <?php
                $sessao = new Zend_Session_Namespace('Menualuno');
                if(count($sessao->Menualuno) > 0){
                    $menu = $sessao->Menualuno;
                } else {
                    $query = 'SELECT SQL_CACHE * FROM MENU_ALUNO WHERE MNA_STA = 1 ORDER BY MNA_ORD ASC';
                    $menu = $db->fetchAll($query);
                    $sessao->Menualuno = $menu;
                    
                    $sessao = new Zend_Session_Namespace('Menualuno_nom');
                    foreach($menu as $men) $sessao->Menualuno_nom[$men['MNA_ARQ']] = $men['MNA_NOM'];
                }
                
                foreach($menu as $men){
                    if($this->data['ALU_ID'] > 0 || $men['MNA_ARQ'] == 'edit'){
            ?>
                <li <?php sel_menu($this->action,$men['MNA_ARQ']); ?>><a href="<?php echo $this->urlbase.'/'.$this->modulo.'/'.$this->controller.'/'.$men['MNA_ARQ'].'/id/'.$this->data['ALU_ID']; ?>"><?php echo $men['MNA_NOM']; ?></a></li>
            <?php } }?>
        </ul>
    </div>
    <?php if($this->data['ALU_ID'] > 0){ ?>
    <div class="row">
        <strong>Status:</strong> <?php echo $status; ?>
        <span class="separador"></span>
        <strong>Turma:</strong> <?php echo $turma; ?> 
        <span class="separador"></span>
        <strong>Pagamento:</strong>
    </div>
    <div class="row tl_aln">
        <?php echo $this->data['ALU_NOM'].' - '.$this->data['ALU_ID']; ?>
    </div>
    <?php } ?>